home *** CD-ROM | disk | FTP | other *** search
- package koala.dynamicjava.interpreter.modifier;
-
- import koala.dynamicjava.interpreter.context.Context;
- import koala.dynamicjava.interpreter.error.CatchedExceptionError;
- import koala.dynamicjava.tree.QualifiedName;
- import koala.dynamicjava.tree.visitor.Visitor;
-
- public class VariableModifier extends LeftHandSideModifier {
- protected QualifiedName name;
- protected Class type;
- protected String representation;
-
- public Object prepare(Visitor var1, Context var2) {
- return var2.get(this.representation);
- }
-
- public void modify(Context var1, Object var2) {
- if (!this.type.isPrimitive() && var2 != null && !this.type.isAssignableFrom(var2.getClass())) {
- ClassCastException var3 = new ClassCastException(this.representation);
- throw new CatchedExceptionError(var3, this.name);
- } else {
- var1.set(this.representation, var2);
- }
- }
-
- public VariableModifier(QualifiedName var1, Class var2) {
- this.name = var1;
- this.type = var2;
- this.representation = var1.getRepresentation();
- }
- }
-